package com.lmm.lcbusiness.lcbusiness.pages.rnpages.plugins;

import com.alibaba.android.arouter.launcher.ARouter;
import com.facebook.react.bridge.Callback;
import com.lmm.dresswisdom.lmmframe.reactnative.BasePlugin;
import com.lmm.dresswisdom.lmmframe.reactnative.annotation.RNPlugin;
import com.lmm.lcbusiness.lcbusiness.config.ReqCodeValue;
import com.lmm.lcbusiness.lcbusiness.pages.rnpages.ReactNativeActivity;

import java.util.Map;

/**
 * Created by xmgong on 2017/12/5.
 */
@RNPlugin(method = "chooseMapLocation")
public class ChooseMapLocationPlugin extends BasePlugin<ReactNativeActivity> {
    public ChooseMapLocationPlugin(ReactNativeActivity act) {
        super(act);
    }

    @Override
    protected void doAction(Map<String, Object> map, Callback callback) {
        double lat = 0, lon = 0;
        if (map.containsKey("lat")) {
            if (!map.get("lat").equals("")) {
                lat = Double.parseDouble(map.get("lat").toString());
            }
        }
        if (map.containsKey("lon")) {
            if (!map.get("lon").equals("")) {
                lon = Double.parseDouble(map.get("lon").toString());
            }
        }
        ARouter.getInstance().build("/app/chooseplace")
                .withDouble("lat", lat)
                .withDouble("lon", lon)
                .navigation(activity, ReqCodeValue.ChoosePointReqCode);
    }
}
